package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1")
@Api(value = "用户行为controller",tags = "用户行为controller")
public class ApBehaviorController {
    //点赞行为服务
    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;

    //阅读行为服务
    @Autowired
    ApReadBehaviorService apReadBehaviorService;

    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;

    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;

    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;

    @PostMapping("/likes_behavior")
    @ApiOperation(value = "点赞或取消点赞")
    public ResponseResult likeBehavior(@RequestBody LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }

    @PostMapping("/read_behavior")
    @ApiOperation(value = "阅读行为")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }

    @PostMapping("/un_likes_behavior")
    @ApiOperation(value = "不喜欢 or 取消不喜欢")
    public ResponseResult unLikesBehavior(@RequestBody UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @PostMapping("/collection_behavior")
    @ApiOperation(value = "收藏 or 取消收藏")
    public ResponseResult collertionBehavior(@RequestBody CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @PostMapping("/article/load_article_behavior")
    @ApiOperation(value = "文章行为")
    public ResponseResult loadArticleBehavior(@RequestBody ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }
}
